#pragma once

#include <cstdio>
#include <string>
#include <map>
 
#include <boost/tokenizer.hpp>
#include <boost/algorithm/string.hpp>

class FormatQualifier {
public:

    static const size_t BUFFER_SIZE = 128;
    constexpr static const char* ERR_CODE = "UNKNOWN";
    constexpr static const char* BASE_CMD = "file --brief --mime-type ";

    FormatQualifier(const std::map<std::string, std::string>& formats);

    std::string getFormat(const std::string& filename) const; 

    std::string getMimeType(const std::string& fmt) const;
private:
    std::string exec(const std::string& cmd) const;
    std::string normalizeFormat(const std::string& fmtstring) const;

    std::map<std::string, std::string> formats_;
 };

